package com.javalab._7thread._3Lock._2Volatile;

public class MyRunnable implements Runnable {

    @Override
    public void run() {
        while (!CommonData.isStop()) {
            // 注意：若在此处执行sleep或者println会引起工作内存与主内存的同步，即使没有使用volatile也能停止下来

            /*System.out.println("")
            try {
                Thread.sleep(100);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }*/
        }
        System.out.println("收到停止信号 stop=>" + CommonData.isStop());
    }
}
